using System;
using System.Collections.Generic;
using System.IO;
//Copyright (c) Microsoft Corporation. All rights reserved.
using System.Text;
using NUnit.Framework;

namespace Microsoft.Office.OneNote.UnitTests
{
	/// <summary>
	/// Tests the SectionTest class.
	/// </summary>
	[TestFixture]
	public class SectionTest
	{
		[SetUp]
		public void Init()
		{
			NotebookRoot root = OneNote.Application.NotebookRoot;

			// Let's create a new notebook:
			Notebook testNotebook = TestUtils.CreateEmptyNotebook();

			// To that notebook, let's create a new section:
			using (HierarchyTransaction addGroup = new HierarchyTransaction(testNotebook))
			{
				this.testSection = new Section("test section");
				testNotebook.AppendChild(testSection);
			}
		}

		[TearDown]
		public void Dispose()
		{
			TestUtils.CloseAndDeleteNotebook((Notebook) this.testSection.Parent);
			this.testSection = null;
		}

		[Test]
		public void Construction()
		{
		}

		[Test]
		public void CanContain()
		{
			Assert.IsTrue(this.testSection.CanContain(new Page()));
			Assert.IsFalse(this.testSection.CanContain(new Section()));
			Assert.IsFalse(this.testSection.CanContain(new SectionGroup()));
			Assert.IsFalse(this.testSection.CanContain(new Notebook()));
			Assert.IsFalse(this.testSection.CanContain(OneNote.Application.NotebookRoot));
		}

		[Test]
		public void AddPage()
		{
			Assert.IsTrue(this.testSection.GetChildCount() == 0);

			using (HierarchyTransaction createPage = new HierarchyTransaction(testSection))
			{
				this.testSection.AppendChild(new Page("Test Group"));
			}

			Assert.IsTrue(this.testSection.GetChildCount() == 1);
		}

		private Section testSection = null;
	}
}